<?php

class Zend_View_Helper_Deviceaddprocessbreadcrumb extends Zend_View_Helper_Abstract {

    private $session;
    private $addHubProgress = array(
        "/devices/add" => "Step 1 - pick device",
        "/devices/addtype" => "Step 2 - define device type", 
        "/devices/addattributes" => "Step 3 - set all attributes and name",
    );
   
    public function deviceaddprocessbreadcrumb($step = 0) {
        $this->session = new Zend_Session_Namespace('addHub');
        if ($step == 0) {
            return $this->generateBreadcrumb();
        } else if ($step == 1) {
            return $this->addHubProgress["/devices/add"];
        } else if ($step == 2) {
            return $this->addHubProgress["/devices/addtype"];
        } else if ($step == 3) {
            return $this->addHubProgress["/devices/addattributes"];
        }
    }

    public function generateBreadcrumb() {
        
        $returnString = "<div id=\"breadcrumb\"><ul class=\"breadcrumb-items\">\n";
        foreach ($this->addHubProgress as $link => $name) {
          $namet = $this->view->translate($name);
         
          if ($link == "/hubs/addagent") {
            if (preg_match("/^(USB|ETH|VIR)/", $this->session->hubType)) {
                $returnString .=  "<li><a href=\"$link\" title=\"$namet\">$namet</a></li>\n";
            } else {
                $returnString .=  "<li>$namet</li>\n";
            }
          } else if ($link == "/hubs/addconfig") {
            if ($this->session->agentType > 0 ) {
                $returnString .=  "<li><a href=\"$link\" title=\"$namet\">$namet</a></li>\n";
            } else {
                $returnString .=  "<li>$namet</li>\n";
            }
          } else if ($link == "/hubs/addservice") {
            if ($this->session->basicConfig == 1) {
                $returnString .=  "<li><a href=\"$link\" title=\"$namet\">$namet</a></li>\n";
            } else {
                $returnString .=  "<li>$namet</li>\n";
            }                            
          } else {
            $returnString .=  "<li><a href=\"$link\" title=\"$namet\">$namet</a></li>\n";                 
          }
        }
        $returnString .= "</ul></div>\n";    
        return $returnString;
    }

}

?>